﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tomahawk.Runtime.Logic;

namespace ActorsAndComponents.Logic
{
    //
    // This example actor class demonstrate how you can add components to actors dynamically, at runtime.
    //

    public class DynamicallyAdded : XActor
    {
        XMaterialMeshComponent meshComponent;

        protected override void OnInitialize()
        {
            base.OnInitialize();

            // Create a XStaticMeshComponent using an archetype that include only the component 
            // properties 

            // NOTE: Passing and empty string as a name, will cause XWorld to autogenerate a
            // name for the new object 

            meshComponent = (XMaterialMeshComponent)XWorld.Instance.CreateObject(typeof(XMaterialMeshComponent),
                this, "", @"Examples.ActorsAndComponents.Content\StaticMesh.xml");
            
            // Add the component this actor

            this.AddComponent(meshComponent);
        
        }
    }
}
